<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式中嵌套组与不记录组</title>
</head>
<body>
    <script>
        let hd = `
        https://www.houdunren.com
        https://houdunren.com
        http://hourenren.com
        `;

        // 原子组中的?:表示记不记录编号
        let reg = /https?:\/\/((?:\w+\.)?\w+\.(?:com|org|cn))/gi;
        console.log(hd.match(reg));

        // console.dir(reg.exec(hd));
        // console.log(reg.lastIndex);
        // console.dir(reg.exec(hd));
        // console.log(reg.lastIndex);
        // console.dir(reg.exec(hd));
        // console.log(reg.lastIndex);
        // console.dir(reg.exec(hd));
        // console.log(reg.lastIndex);

        let mm = [];
        while(res = reg.exec(hd)){
            mm.push(res[1]);
        }
        console.log(mm);
    </script>
</body>
</html>